import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../pages/Index/index.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Index',
    component: Index
  },
  {
    path:'/topic/:id',//动态路由
    name:'detail',
    component: () => import('../pages/topic/index.vue'),
    props:true //开启props传参，把id传到子组件中去
  },
  {
    path: '/user/:loginname',
    name: 'User',
    component: () => import('../pages/user/index.vue'),
    props:true //开启props传参，把id传到子组件中去
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../pages/login/index.vue')
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../pages/register02/index.vue')
  },
  {
    path: '/registerData',
    name: 'RegisterData',
    component: () => import('../pages/edit/index.vue')
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
